<template>
  <slide-view
    v-empty="false" :body-style="{padding: 0, height: '100%'}"
    class="d-view"
    xs-empty-icon="nopermission"
    xs-empty-text="暂无权限">
    <div class="close-button" @click="hideView">
      <i class="el-icon-close"/>
    </div>
    <div v-loading="loading" class="section">
      {{ userName }}
      <div class="section-header">
        <div class="section-mark"/>
        <div class="section-title">基本信息</div>
      </div>
      <div class="showDetailContent">
        <div v-for="(item,index1) in detailData" class="showDetail" :key="index1">
          <div class="title">{{ item.title }}</div>
          <div v-for="(item2,index2) in item.resources" class="content" :key="index2">
            <div class="min-title">{{ item2.title }}</div>
            <flexbox v-for="(item3,index3) in item2.files" class="min-content" :key="index3">
              <div>{{ item3.title }}：{{ statusList[item3.studyStatus] }}</div>
              <div>总时长：{{ item3.standardStudySeconds | time }}</div>
              <div>已观看：{{ item3.studiedSeconds | time }}</div>
            </flexbox>
          </div>
        </div>
      </div>

    </div>
  </slide-view>


</template>
<style lang="scss" scoped>
  .section {
    height: 100%;
    padding: 30px;
    position: relative;
    background-color: white;
    margin-top: 8px;
    .section-mark {
      border-left: 2px solid #46cdcf;
      height: 10px;
    }

    .section-header {
      display: flex;
      align-items: center;
      padding: 5px 15px;
    }
    .section-title {
      font-size: 13px;
      color: #333;
      margin-left: 8px;
      flex-shrink: 0;
    }
  }
  .showDetailContent {
    height: calc(100% - 40px);
    overflow-y: auto;
    .showDetail {
      padding: 15px;
      .title {
        font-size: 20px;
      }
      .content {
        padding: 10px 20px;
        .min-title {
          margin-bottom: 10px;
          font-size: 18px;
        }
        .min-content {
          justify-content: space-between;
          margin: 10px;
          flex-wrap: wrap;
          div {
            white-space: pre-wrap;
            margin-bottom: 8px;
          }
        }
      }
    }
  }

  .d-view {
    position: fixed;
    width: 61%;
    top: 0px;
    bottom: 0px;
    right: 0px;
  }
  .h-section {
    position: relative;
    padding: 8px 17px 15px 17px;
    min-height: 58px;
    .h-item {
      .h-title {
        font-size: 12px;
        color: #777;
      }
      .h-value {
        min-height: 14px;
        margin-top: 8px;
        font-size: 13px;
        color: #333333;
      }
    }
  }
  /* 关闭侧边框的按钮 */
  .el-card {
    overflow: visible;
  }

  .close-button {
    display: block;
    width: 40px;
    height: 40px;
    padding: 5px;
    background-color: #ff6767;
    border-radius: 5px 0 0 5px;
    cursor: pointer;
    position: absolute;
    left: -41px;
    top: 10px;
  i {
    color: white;
    font-size: 30px;
  }
  }


</style>
<script>
import SlideView from '@/components/SlideView'
import {
  // eslint-disable-next-line no-unused-vars
  reportCourse
} from '../../../api/kmsmanagement/report'
import { timeKeepFormatter } from '@/utils/index.js'
export default {
  components: {
    SlideView
  },
  filters: {
    time(val) {
      return timeKeepFormatter(Number(val))
    }
  },
  props: {

  },
  data() {
    return {
      detailData: [],
      userName: '',
      loading: false,
      statusList: ['未学习', '学习中', '学习完成']
    }
  },
  methods: {
    hideView() {
      this.$emit('hideSlider', true)
    },
    getDetail(val) {
      this.loading = true
      this.userName = val.username
      reportCourse({ userId: val.userId }).then(res => {
        this.detailData = res.data.list
        this.loading = false
      }).catch(() => {
        this.loading = false
      })
    }
  }
}
</script>
